Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 | /* eslint-disable @typescript-eslint/no-unused-vars */ /* eslint-disable @next/next/no-img-element */ 'use client'; import React from 'react'; import { cn } from '@/lib/utils'; import { getCategoryGradient } from '@/constants/categoryColors'; export type CardVariant = 'default' | 'glassmorphism' | 'gradient' | 'category'; export type CardSize = 'sm' | 'md' | 'lg' | 'xl'; interface UnifiedCardProps { children: React.ReactNode; variant?: CardVariant; size?: CardSize; hover?: boolean; className?: string; category?: string; // For category variant onClick?: () => void; } const sizeClasses: Record<CardSize, string> = { sm: 'p-3', md: 'p-4', lg: 'p-6', xl: 'p-8'}; const variantClasses: Record<CardVariant, string> = { default: 'bg-slate-800/30 border border-slate-700/50', glassmorphism: 'bg-slate-900/80 backdrop-blur-md border border-slate-700/50', gradient: 'bg-gradient-to-br from-slate-800/50 to-slate-900/50 border border-slate-700/30', category: '', // Will be set dynamically based on category prop }; const hoverClasses = 'transition-all duration-200 hover:bg-slate-700/50 hover:scale-[1.02] cursor-pointer'; export function UnifiedCard({ children, variant = 'default', size = 'md', hover = false, className, category, onClick}: UnifiedCardProps) { const baseClasses = 'rounded-lg'; const sizeClass = sizeClasses[size]; let variantClass = variantClasses[variant]; // If variant is category and category is provided, use category gradient if (variant === 'category' && category) { variantClass = `${getCategoryGradient(category)} border border-slate-700/30`; } const hoverClass = hover ? hoverClasses : ''; return ( <div className={cn( baseClasses, sizeClass, variantClass, hoverClass, className )} onClick={onClick} > {children} </div> ); } // Specialized card components built on UnifiedCard interface ContentCardProps { title: string; subtitle?: string; imageUrl?: string; category?: string; onClick?: () => void; className?: string; children?: React.ReactNode; } export function ContentCard({ title, subtitle, imageUrl, category, onClick, className, children}: ContentCardProps) { return ( <UnifiedCard variant="glassmorphism" size="sm" hover onClick={onClick} className={className} > {imageUrl && ( <div className="aspect-[2/3] w-full mb-3 rounded-lg overflow-hidden bg-slate-800/50"> <img src={imageUrl} alt={title} className="w-full h-full object-cover" loading="lazy" /> </div> )} <div className="space-y-1"> <h3 className="font-medium text-sm text-white truncate" title={title}> {title} </h3> {subtitle && ( <p className="text-xs text-slate-400 truncate" title={subtitle}> {subtitle} </p> )} {children} </div> </UnifiedCard> ); } interface StatsCardProps { title: string; value: string | number; subtitle?: string; icon?: React.ReactNode; trend?: 'up' | 'down' | 'neutral'; trendValue?: string; className?: string; } export function StatsCard({ title, value, subtitle, icon, trend, trendValue, className}: StatsCardProps) { const trendColors = { up: 'text-green-500', down: 'text-red-500', neutral: 'text-slate-400'}; return ( <UnifiedCard variant="glassmorphism" size="lg" className={className}> <div className="flex items-center justify-between mb-3"> <h3 className="text-sm font-medium text-slate-400">{title}</h3> {icon && <div className="text-slate-400">{icon}</div>} </div> <div className="space-y-2"> <p className="text-3xl font-bold text-white">{value}</p> {(subtitle || trendValue) && ( <div className="flex items-center gap-2 text-xs"> {trendValue && trend && ( <span className={trendColors[trend]}>{trendValue}</span> )} {subtitle && <span className="text-slate-400">{subtitle}</span>} </div> )} </div> </UnifiedCard> ); } interface ActionCardProps { title: string; description?: string; icon?: React.ReactNode; onClick?: () => void; className?: string; variant?: CardVariant; } export function ActionCard({ title, description, icon, onClick, className, variant = 'default'}: ActionCardProps) { return ( <UnifiedCard variant={variant} size="md" hover onClick={onClick} className={className} > <div className="flex items-start gap-3"> {icon && ( <div className="flex-shrink-0 p-2 bg-slate-700/50 rounded-lg"> {icon} </div> )} <div className="flex-1 min-w-0"> <h3 className="font-medium text-white mb-1">{title}</h3> {description && ( <p className="text-sm text-slate-400 line-clamp-2">{description}</p> )} </div> </div> </UnifiedCard> ); } interface ListCardProps { items: Array<{ id: string | number; title: string; subtitle?: string; icon?: React.ReactNode; action?: React.ReactNode; }>; className?: string; } export function ListCard({ items, className }: ListCardProps) { return ( <UnifiedCard variant="glassmorphism" size="sm" className={className}> <div className="space-y-2"> {items.map((item, index) => ( <div key={item.id} className={cn( 'flex items-center gap-3 p-2 rounded-lg hover:bg-slate-700/30 transition-colors', index !== items.length - 1 && 'border-b border-slate-700/30' )} > {item.icon && ( <div className="flex-shrink-0 text-slate-400">{item.icon}</div> )} <div className="flex-1 min-w-0"> <p className="text-sm font-medium text-white truncate"> {item.title} </p> {item.subtitle && ( <p className="text-xs text-slate-400 truncate">{item.subtitle}</p> )} </div> {item.action && <div className="flex-shrink-0">{item.action}</div>} </div> ))} </div> </UnifiedCard> ); } interface EmptyCardProps { title: string; description?: string; icon?: React.ReactNode; action?: React.ReactNode; className?: string; } export function EmptyCard({ title, description, icon, action, className}: EmptyCardProps) { return ( <UnifiedCard variant="default" size="lg" className={cn('text-center', className)}> {icon && ( <div className="mx-auto mb-4 w-12 h-12 bg-slate-800/50 rounded-full flex items-center justify-center text-slate-400"> {icon} </div> )} <h3 className="text-lg font-medium text-white mb-2">{title}</h3> {description && ( <p className="text-slate-400 mb-4 max-w-md mx-auto">{description}</p> )} {action && <div className="mt-4">{action}</div>} </UnifiedCard> ); } |